package com.designed.pattern.creational.singleton.lasy;

import java.io.Serializable;
import java.util.Objects;

/**
 * 懒汉式
 * @author yifei
 * @date 2024/3/28
 **/
public class LazySingleton implements Serializable {

    private static LazySingleton lazySingleton =null;
    private LazySingleton(){}

    public static synchronized LazySingleton getInstance(){
        if(lazySingleton == null){
            lazySingleton = new LazySingleton();
        }
        return lazySingleton;
    }

    private Object readResolve(){
        return lazySingleton;
    }
}
